<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="../metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">

    <title>Test Select - Metro 4 :: Popular HTML, CSS and JS library</title>

</head>
<body class="m4-cloak">
<div class="container">
    <h1>Select test page</h1>

    <div class="example">
        <select data-role="select" multiple>
            <OPTION value = "arknoid2" data-display = "arknoid2"> Arkanoid - Revenge of DOH (World) </OPTION>
            <OPTION value = "arkanoid" data-display = "arkanoid"> Arkanoid (World, older) </OPTION>
            <OPTION value = "astrob" data-display = "astrob"> Astro Blaster (version 3) </OPTION>
            <OPTION value = "bankp" data-display = "bankp"> Bank Panic </OPTION>
        </select>
    </div>

    <br>
    <div class="example">
        <select data-role="select" data-show-group-name="true" data-clear-button="true">
            <optgroup label="Microsoft">
                <option value="microsoft-usa">USA</option>
                <option value="microsoft-usa-alabama">Alabama</option>
                <option value="microsoft-usa-alaska">Alaska</option>
            </optgroup>

            <optgroup label="Apple">
                <option value="apple-usa">USA</option>
                <option value="apple-usa-alabama">Alabama</option>
                <option value="apple-usa-alaska">Alaska</option>
            </optgroup>
        </select>
    </div>

    <br>
    <div class="example">
        <select data-role="select" data-show-group-name="true" data-clear-button="true" class="input-large">
            <optgroup label="Microsoft">
                <option value="microsoft-usa">USA</option>
                <option value="microsoft-usa-alabama">Alabama</option>
                <option value="microsoft-usa-alaska">Alaska</option>
            </optgroup>

            <optgroup label="Apple">
                <option value="apple-usa">USA</option>
                <option value="apple-usa-alabama">Alabama</option>
                <option value="apple-usa-alaska">Alaska</option>
            </optgroup>
        </select>
    </div>

    <br>
    <div class="example">
        <select data-role="select" id="select1" data-show-group-name="true">
            <optgroup label="Physical servers">
                <option value="dedicated_corei3_hp">Core i3 (hp)</option>
                <option value="dedicated_pentium_hp">Pentium (hp)</option>
                <option value="dedicated_smart_corei3_hp">Smart Core i3 (hp)</option>
            </optgroup>
            <optgroup label="Virtual hosting">
                <option value="mini">Mini</option>
                <option value="site">Site</option>
                <option value="portal">Portal</option>
            </optgroup>
            <optgroup label="Virtual servers">
                <option value="evps0">eVPS-TEST (30 дней)</option>
                <option value="evps1" selected="selected">eVPS-1</option>
                <option value="evps2">eVPS-2</option>
            </optgroup>
        </select>
    </div>

    <br>

    <div class="example">
        <select data-role="select" multiple id="select2"
                data-clear-button="true"
                data-cls-option-group="text-bold fg-orange"
                data-show-group-name="true"
                data-cls-group-name="fg-red"
                data-short-tag="false">
            <optgroup label="Physical servers">
                <option value="dedicated_corei3_hp">Core i3 (hp)</option>
                <option value="dedicated_pentium_hp">Pentium (hp)</option>
                <option value="dedicated_smart_corei3_hp">Smart Core i3 (hp)</option>
            </optgroup>
            <optgroup label="Virtual hosting">
                <option value="mini">Mini</option>
                <option value="site">Site</option>
                <option value="portal">Portal</option>
            </optgroup>
            <optgroup label="Virtual servers">
                <option value="evps0">eVPS-TEST (30 дней)</option>
                <option value="evps1" selected="selected">eVPS-1</option>
                <option value="evps2">eVPS-2</option>
            </optgroup>
        </select>
    </div>

    <br>
    <br>
    <div class="example">
        <div class="d-flex flex-row no-wrap flex-align-start">
            <select id="select3" data-role="select" data-prepend="Select item:"></select>
            <button class="button" onclick="fillSelect()">Fill select</button>
        </div>
    </div>

    <br>
    <br>
    <div class="example">
        <div>
            <BUTTON id="SET_2"
                    class="button rounded bg-grayBlue bg-darkGrayBlue-hover text-bold fg-white"
                    data-id="2">Ball & Paddle</BUTTON>
            <BUTTON id="SET_6"
                    class="button rounded bg-grayBlue bg-darkGrayBlue-hover text-bold fg-white"
                    data-id="6">Board Game</BUTTON>
        </div>
        <SELECT id="CATEGORIES" name="categories"
                class="input-small text-bold"
                data-role="select"
                data-show-group-name="true"
                data-cls-option-group="text-bold bg-white fg-grayBlue"
                data-label="Categories"
                data-cls-label="text-bold fg-grayBlue"
                data-clear-button="true"
                size="1">
            <OPTION value="">&nbsp;</OPTION>
            <OPTGROUP label="Arcade">
                <OPTION value="1">Pinball</OPTION>
            </OPTGROUP>
            <OPTGROUP label="Ball & Paddle">
                <OPTION value="2">Breakout</OPTION>
                <OPTION value="3">Jump and Touch</OPTION>
                <OPTION value="4">Misc.</OPTION>
                <OPTION value="5">Pong</OPTION>
            </OPTGROUP>
            <OPTGROUP label="Board Game">
                <OPTION value="6">Backgammon</OPTION>
                <OPTION value="7">Bridge Machine</OPTION>
                <OPTION value="8">Cards</OPTION>
                <OPTION value="9">Checker Machine</OPTION>
                <OPTION value="10">Chess Machine</OPTION>
                <OPTION value="11">Dame Machine</OPTION>
            </OPTGROUP>
        </SELECT>
    </div>
</div>

<script src="../metro/js/metro.js?ver=@@b-version"></script>
<script>
    var sel = $("@select");
    var Utils = Metro.utils;

    function fillSelect(){
        var select = Metro.getPlugin("#select3", "select");
        var options = {
            "0": "NEW DIPSWITCH",
            "T": "Time",
            "L": "Lives",
            "H": "Health",
            "C": "Coins"
        };
        console.log(options);
        select.data(options);
        select.val("");
    }

    // sel.on("change", function () {
    //     console.log("changed");
    // });
    //
    // sel.on("drop", function (e) {
    //     console.log("down");
    //     // var dropContainer = $(e.detail.list).closest(".drop-container").removeClass("drop-up");
    //     //
    //     // if (!Utils.inViewport(dropContainer[0])) {
    //     //     dropContainer.addClass("drop-up");
    //     // }
    // });
    //
    // sel.on("up", function () {
    //     console.log("up");
    // });

    $(document).on("click", "[id^='SET_']", function(e) {
        e.preventDefault();

        var tID=$(this).attr("data-id");

        Metro.getPlugin("#CATEGORIES", "select").val(tID);
        $("#CATEGORIES").focus();

    });
</script>
</body>
</html>
